package com.hsc.www.hello.yml;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;


/**
 * * 将配置文件中配置的每一个属性的值，映射到这个组件中
 * * @ConfigurationProperties：告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定；
 * *      prefix = "person"：配置文件中哪个下面的所有属性进行一一映射
 * *
 * * 只有这个组件是容器中的组件，才能容器提供的@ConfigurationProperties功能；
 * *
 */
@Component
@PropertySource(value = {"classpath:jdbc.properties"})
public class Student {
    @Value("${person.lastName}")
    private String lastName;

    @Value("${jdbc.userName}")
    private String jdbcUserName;

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getJdbcUserName() {
        return jdbcUserName;
    }

    public void setJdbcUserName(String jdbcUserName) {
        this.jdbcUserName = jdbcUserName;
    }

    @Override
    public String toString() {
        return "Student{" +
                "lastName='" + lastName + '\'' +
                ", jdbcUserName='" + jdbcUserName + '\'' +
                '}';
    }
}